package ru.niir.goodfil.audit.ui.beans.converters;

import org.apache.commons.lang.NotImplementedException;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import java.text.SimpleDateFormat;

public class TimestampConverter implements Converter {
    private static final SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");

    public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String s) {
        throw new NotImplementedException();
    }

    public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object o) {
        try {
            return sdf.format(o);
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }
}
